﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gbu.BLTool;
using Gbu.BLTool.BaseTool;
using Gbu.BLTool.Entitys;
using Gbu.BLTool.Logics;

namespace RestSharpTest
{
    class Program
    {
        private static string name;
        private static int age;
        private static string sex;

        static void Main(string[] args)
        {
            Console.WriteLine("Init.....");
            UserInfoBl bl=new UserInfoBl();
            var us = new UserReq()
                {
                    Id = "1"
                };

            Console.WriteLine("Start request for userInfo.");
            bl.GetUserInfo(OnCallback,us);


            Console.ReadKey();
        }

        private static void OnCallback(CommResponseEntity<UserRet> ret)
        {
            Console.WriteLine("On Response callback started.");
            if (ret.Status == 0 && ret.MessageCode == 0)
            {
                name = ret.Entity.Name;
                age = ret.Entity.Age;
                sex = ret.Entity.Sex != 1 ? "女" : "男";
                Console.WriteLine(string.Format("UserInfo: name:{0},Sex:{1},Age:{2}",name,sex,age));
            }
            else
            {
                Console.WriteLine("Catch user data error," + ret.Message);
            }

            Console.WriteLine("On Response callback completed.");
        }
    }
}
